$(function(){
	$('#fdfs').datagrid({
		title:'文件列表',
		fit:true ,
		fitColumns : true,
		border : false,
		pagination : true,
		idField : 'fsId',
		rownumbers : true,
		singleSelect:true,
		pagination:true,
		rownumbers:true,
		sortName: 'uploadTime',
		sortOrder: 'desc',
		remoteSort: true,
		striped: true,
		frozenColumns:[[
            {title:'文件标识',field:'fsId',sortable:true}
		]],
		url:ctx+'/filemanage/listFileInfoToJson',
		columns:[[
			{field:'uploadTime',title:'创建时间',width:210,sortable:true,
				formatter:function(value){
					var ss="";
					if(value!=null){
						ss=formatTimeStampDate(value);
					}
					return ss;
				}	
			},
			{field:'fileId',title:'文件路径',width:300,sortable:true},
			{field:'fileName',title:'文件名称',width:getWidth(6),sortable:true},
			{field:'slaveName',title:'文件参数',width:getWidth(6),sortable:true},
			{field:'fileType',title:'文件类型',width:getWidth(6),sortable:true,
				formatter:function(value){
	        		var ss = value;
	        		if(value!=null){
	        			if(value=="IMG") {
	        				ss = "图片类型";
	        			}
	        			if(value=="DOC") {
	        				ss = "文档类型";
	        			} 
	        		}
	        		return ss;
	        	}	
			},
			{field:'fileSize',title:'文件大小',width:getWidth(6),sortable:true,
				formatter:function(value,rowData,rowIndex){
	        		return rowData.stringFileSize;
	        	}
			},
			{field:'systemId',title:'系统编号',width:getWidth(6),sortable:true},
			{field:'fileDownloadCounts',title:'下载次数',width:getWidth(6),sortable:true},
			{field:'businessId',title:'业务编号',width:getWidth(6),sortable:true},
			{field:'opera',title:'操作',
				formatter:function(value,rowData,rowIndex){
						return "<a target='_blank' href='"+downloadUrl+"?fsId="+rowData.fsId+"'>下载文件</a>";
					//return "<a href='javascript:openDownloadWindow(\""+rowData.fsId+"\");'>下载下载</a>";
	        	}		
			}
		]]
	});
	
	
	// 添加easyui日期插件
	$('#start').datebox({
		formatter : function(date) {
			var y = date.getFullYear();
			var m = date.getMonth() + 1;
			var d = date.getDate();
			return y + '-' + m + '-' + d;
		}
	});
	$('#end').datebox({
		formatter : function(date) {
			var y = date.getFullYear();
			var m = date.getMonth() + 1;
			var d = date.getDate();
			return y + '-' + m + '-' + d;
		}
	});
	// 设置日期只读
	$(".datebox :text").attr("readonly", "readonly");
});
function openDownloadWindow(fsId) {
	var fileId = "";
	window.showModalDialog(ctx+"/filemanage/openDownloadWindow?fsId=" + fsId);
}

//js方法：序列化表单 			
function serializeForm(form){
	var obj = {};
	$.each(form.serializeArray(),function(index){
		if(obj[this['name']]){
			obj[this['name']] = obj[this['name']] + ','+this['value'];
		} else {
			obj[this['name']] =this['value'];
		}
	});
	return obj;
}

/**
 * 分页模糊查询
 */
function searchFdfs(){
	$('#fdfs').datagrid("clearChecked");
	$('#fdfs').datagrid('load' ,serializeForm($('#fdfsForm')));	    
}
/**
 * 重置账号管理查询表单
 */
function clearForm(){
	$('#fdfsForm').form('clear');
}